<?php

namespace Apps\AppApi\Method\User;


use Apps\AppApi\Method\BaseMethod;
use Apps\Common\Models\BpFavorites;

/**
 * 取消关注美容院
 * @author      545
 * @date        2016年1月12日
 * @version     1.1.2
 * @copyright   Copyright 2015 meelier.com
 */
class delete extends BaseMethod
{
    public function run()
    {
    	if(false == $this->verifyUserAuth()){
    		return false;
    	}
    	$id = $this->getDataItem('id');
    	$userId = $this->getUserAuth()->userId;
    	$bp = BpFavorites::findFirst("bp_id = {$id} and user_id = {$userId} ");
//     	$bp = BpFavorites::find(["where"=>"bp_id = ".$id." and user_id =". $userId]);
    	
    	if($bp){
    	    $stauts = $bp->delete();

    	    if ($stauts){
    	        $this->setResult(['success'=>1,'message'=>'取消成功！']);
    	    }
    		else {
    		    $this->setResult(['success'=>0,'message'=>'取消失败！']);
    		}
    	}else{
    		$this->setResult(['success'=>0,'message'=>'取消失败！']);
    	}
    }


}